package com.shawn.spring.boot.mybatisplus.mapper;

import com.shawn.spring.boot.mybatisplus.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.SelectKey;

/**
 * 角色 Mapper 接口
 *
 * @author shawn
 * @since 2020-08-30
 */
public interface RoleMapper extends BaseMapper<Role> {

  @Insert({
    "insert into t_role (role_name, remark, ",
    "create_time, update_time, ",
    "is_deleted)",
    "values (#{roleName,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, ",
    "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
    "#{isDeleted,jdbcType=TINYINT})"
  })
  @SelectKey(
      statement = "SELECT LAST_INSERT_ID()",
      keyProperty = "roleId",
      before = false,
      resultType = Long.class)
  int insertReturnKey(Role record);
}
